package model.teacher;

import java.io.Serializable;
import java.util.ArrayList;

import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlRootElement;

import model.Link;

@XmlRootElement(name="department")
public class Department extends Link implements Serializable
{
	private static final long serialVersionUID = -1263358969774458721L;

	private static int i = 0;
	
	@XmlAttribute
	private String id = "";
	
	@XmlAttribute
	private String name = "";
	
	@XmlElement(name = "teacher")
	private ArrayList<Teacher> teachers = new ArrayList<Teacher>();
	
	public Department() {}
	
	public Department(String name)
	{
		i++;
		this.id = i + "";
		this.name = name;
	}
	
	public Teacher createTeacher(String name, String unit)
	{
		Teacher teacher = new Teacher(name, unit);
		teachers.add(teacher);
		return teacher;
	}

	public ArrayList<Teacher> getTeachers()
	{
		return teachers;
	}
	
	public String toString()
	{
		String out = "";
		for (int i = 0; i < teachers.size(); i++)
		{
			out += teachers.get(i) + "\n";
		}
		return "Department -> Name: " + name + "\n" + out;
	}

	public String getId()
	{
		return id;
	}

	public void setId(String id)
	{
		this.id = id;
	}

	public String getName()
	{
		return name;
	}
}
